package net.yunxinyong.cec.service.impl;


import net.yunxinyong.cec.entity.EcnomicBrances;
import net.yunxinyong.cec.entity.EcnomicBrancesExample;
import net.yunxinyong.cec.mapper.EcnomicBrancesMapper;
import net.yunxinyong.cec.service.BranceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class BranceServiceImpl implements BranceService {
    @Autowired
    private EcnomicBrancesMapper ecnomicBrancesMapper;
    @Override
    public void insert(EcnomicBrances ecnomicBrances) {
        ecnomicBrances.setCreateTime(new Date());
        ecnomicBrancesMapper.insertSelective(ecnomicBrances);
    }

    @Override
    public void insertList(List<EcnomicBrances> brancesList,Long id) {
        for (EcnomicBrances ecnomicBrances:brancesList){
            ecnomicBrances.setCreateTime(new Date());
            ecnomicBrances.setEcnomicId(id);
            ecnomicBrancesMapper.insertSelective(ecnomicBrances);
        }
    }

    @Override
    public List<EcnomicBrances> getListById(Long id) {
        EcnomicBrancesExample ecnomicBrancesExample = new EcnomicBrancesExample();
        ecnomicBrancesExample.createCriteria().andEcnomicIdEqualTo(id);
        return ecnomicBrancesMapper.selectByExample(ecnomicBrancesExample);
    }

    @Override
    public void update(EcnomicBrances ecnomicBrances) {
        ecnomicBrancesMapper.updateByPrimaryKeySelective(ecnomicBrances);
    }
}
